package com.huike.clues.service.impl;


import com.huike.clues.domain.TbClueTrackRecord;
import com.huike.clues.domain.vo.ClueTrackRecordVo;
import com.huike.clues.mapper.TbClueTrackRecordMapper;
import com.huike.clues.service.ITbClueTrackRecordService;
import com.huike.common.core.page.TableDataInfo;
import com.huike.common.utils.DateUtils;
import com.huike.common.utils.SecurityUtils;
import com.huike.common.utils.bean.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

/**
 * 线索跟进记录Service业务层处理
 * @date 2022-04-22
 */
@Service
public class TbClueTrackRecordServiceImpl implements ITbClueTrackRecordService {

    @Autowired
    private TbClueTrackRecordMapper tbClueTrackRecordMapper;

    @Override
    public void add(ClueTrackRecordVo tbClueTrackRecord) {
        tbClueTrackRecord.setType("0");
        tbClueTrackRecord.setCreateBy(SecurityUtils.getUsername());
        tbClueTrackRecord.setCreateTime(LocalDateTime.now());
        tbClueTrackRecord.setUpdateBy(SecurityUtils.getUsername());
        tbClueTrackRecord.setUpdateTime(LocalDateTime.now());
        tbClueTrackRecordMapper.insert(tbClueTrackRecord);
    }

    @Override
    public TableDataInfo list(Long clueId) {
        List<TbClueTrackRecord> rows = new ArrayList<>();
        List<TbClueTrackRecord> tbClueTrackRecord=tbClueTrackRecordMapper.selectByClueId(clueId);
        for (TbClueTrackRecord clueTrackRecord : tbClueTrackRecord) {
            rows.add(clueTrackRecord);
        }
        TableDataInfo tableDataInfo=new TableDataInfo();
        tableDataInfo.setRows(rows);
        tableDataInfo.setTotal(1);
        tableDataInfo.setCode(200);
        tableDataInfo.setMsg("查询成功");
        return tableDataInfo;
    }
}
